<?php
class PNBlockUserTopPostArray extends PNObjectExArray {
  function PNBlockUserTopPostArray($init=null, $where='')
  {
    $this->PNObject();

    $this->_objType       = 'innoforum_posts';
    $this->_objField      = 'id';
    $this->_objPath       = 'form';
    $this->_objGroup      = 'pst_cr_uid';
    $this->_objColumnExArray = array( 'count_post'  => 'COUNT(*)');

    $this->_objJoin[]     = array ( 'join_table'  =>  'users',
                            'join_field'          =>  array('uname','email'),
                            'object_field_name'   =>  array('user_name','user_email'),
                            'compare_field_table' =>  'cr_uid',
                            'compare_field_join'  =>  'uid');


    $this->_init($init, $where);
  }

  function genFilter(){
    $wheres = array();
    $wheres[] = "pst_cr_uid > 2";
    //only current month
    $wheres[] = "MONTH(pst_cr_date) = MONTH(NOW()) AND YEAR(pst_cr_date) = YEAR(NOW())";
    return implode(' AND ', $wheres) ;
  }
  
  function genSort(){
    return "ORDER BY count_post DESC";
  }
}